package com.adingxiong.cft.config;

import com.adingxiong.cft.config.component.SecurityConfig;
import com.adingxiong.cft.service.ITUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
 * @ClassName AppSecurityConfig
 * @Description TODO
 * @Author xiongchao
 * @Date 2020/9/23 16:02
 **/
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class AppSecurityConfig extends SecurityConfig {

    @Autowired
    private ITUserService userService;

    @Bean
    public UserDetailsService userDetailsService() {
        //获取登录用户信息
        return username -> userService.loadByUserName(username);
    }

}
